package com.mrobuy.jdvc.dao.impl;

import com.mrobuy.jdvc.dao.SyncLogDao;
import com.mrobuy.jdvc.entity.SyncLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;

@Repository("syncLogDao")
public class SyncLogDaoImpl extends CommonDaoImpl implements SyncLogDao {

    private static Logger LOG = LoggerFactory.getLogger(SyncLogDao.class);

    @Override
    public List<SyncLog> list(String shopName, String name) {

        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * from SYNC_LOG where SHOPNAME = ? and NAME = ? ");
        try {
            List<SyncLog> list = getJdbcTemplate().query(sql.toString(), new Object[]{shopName, name}, new BeanPropertyRowMapper(SyncLog.class));
            return list;
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }

        return Collections.EMPTY_LIST;

    }
}
